package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.pageResult;
import cn.itcast.hotel.pojo.RequestParam;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;

    @PostMapping("/list")
    public pageResult searchByParam(@RequestBody RequestParam param) throws Exception{
        return hotelService.searchByParam(param);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParam param) throws Exception{
        return hotelService.filters(param);
    }

    @GetMapping("/suggestion")
    public List<String> getSuggestions(@org.springframework.web.bind.annotation.RequestParam("key") String prefix) {
        return hotelService.getSuggestions(prefix);
    }
}
